import tkinter
def class_start():
    label.config(text="大数据班上课")
def class_end():
    label.config(text="大数据班下课")
def lecture(i):
    label.config(text=f"正在讲课{i}")
root = tkinter.Tk()
root.title("课程展示")
root.geometry("600x600")
# 实例化标签（label）组件
label = tkinter.Label(root, text="付老师课堂")
label.pack()
# 创建按钮1,并设置按钮名称“上课”
button1 = tkinter.Button(root, text="上课",
                         command=class_start,
                         width = 7, height = 1)
# 把按钮1添加到主界面并放到界面左侧
button1.pack(side=tkinter.LEFT)
# 创建按钮2,并设置按钮名称“下课”
button2 = tkinter.Button(root, text="下课",
                         command=class_end,
                         width = 7, height = 1)
# 把按钮2添加到主界面并放到界面右侧
button2.pack(side=tkinter.RIGHT)
# 创建讲课按钮
for i in range(1, 11):
    button = tkinter.Button(root, text=f"讲课{i}",
                            # 这里将参数绑定正确，使用num接收当前循环的i值
                            command=lambda num=i: lecture(num),
                            width = 7, height = 1)
    button.pack(side=tkinter.TOP)
root.mainloop()